package com.hibuy.pc.service.shiro.impl;

import com.hibuy.pc.mapper.shiro.PermissionMapper;
import com.hibuy.pc.model.shiro.Permission;
import com.hibuy.pc.model.shiro.Role;
import com.hibuy.pc.model.shiro.User;
import com.hibuy.pc.service.shiro.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.List;
import java.util.Set;

/**
 * Created by admin on 2017/12/27.
 */
@Service
public class PermissionServiceImpl implements PermissionService {

    @Autowired
    private PermissionMapper permissionMapper;

    @Override
    public User findByUserEmail(String email) {

        return  permissionMapper.findByUserEmail(email);
    }

    @Override
    public Set<String> getRolesName(Integer userId) {
        return permissionMapper.getRolesName(userId);
    }

    @Override
    public List<Role> getRoleList(Integer userId) {
        return permissionMapper.getRoleList(userId);
    }

    @Override
    public Collection<String> getPermissionsName(Integer roleId) {
        return permissionMapper.getPermissionsName(roleId);
    }

    @Override
    public List<Permission> getPermissions() {
        return permissionMapper.getPermissions();
    }

    @Override
    public Permission addPermission(Permission permission) {
        return permissionMapper.addPermission(permission);
    }
}
